package org.springframework.cloud.openfeign;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cglib.proxy.Enhancer;

@Slf4j
@Data
public class DynamicFeginClientFactoryBean extends FeignClientFactoryBean {
    @Override
    public Object getObject() throws Exception {
        Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(this.getType());
        enhancer.setCallback(new DynamicFeignProxy(this));
        return enhancer.create();
    }

    public Object getSuperClient() throws Exception {
        return super.getObject();
    }

    @Override
    public <T> T get(FeignContext context, Class<T> type) {
        return super.get(context, type);
    }

}
